package com.abing.observer.test3.event.listener;

import com.abing.observer.test3.event.OrderMessageEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * @date 2019/5/2121:34
 */
@Component
public class EmailListener implements ApplicationListener<OrderMessageEvent> {
    @Override
    @Async
    public void onApplicationEvent(OrderMessageEvent event) {
        //如何获取到当前容器下面所有的观察者呢？反射机制获取ApplicationListener 接口下面子类
        System.out.println(Thread.currentThread().getName()+"开始发送邮件消息内容:" + event.getJsonObject().toJSONString());
    }
}

